package cn.shujuhai.cms.controller.column;


import cn.shujuhai.cms.service.thymeleaf.ColumnService;
import cn.shujuhai.common.aop.SysLog;
import cn.shujuhai.common.domain.PageRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: zhangDeZhong
 * @Date: 2024/12/5 12:01
 * @Description: 提供栏目模板访问接口
 **/
@RestController
@RequestMapping("/cms/column")
@RequiredArgsConstructor
public class ColumnController {

    private final ColumnService columnService;


    /**
     * 全站检索文章
     *
     * @param key         搜索关键字
     * @param pageRequest 分页对象
     * @return 渲染后的模板内容
     */
    @SysLog(value = "访问搜索模板页面", operationType = "查询", module = "前台模块")
    @PostMapping("/{url}")
    public String searchArticles(@PathVariable String url,
                                 @RequestParam(defaultValue = "") String key,
                                 @Valid PageRequest pageRequest) {
        return columnService.getColumn(url, key, pageRequest.getPageNum(), pageRequest.getPageSize());
    }


}
